{% extends 'food/base.html' %}

{% block content %}
<div class="row">
    <div class="col-md-4">
        <div class="stats-card mb-4">
            <div class="d-flex justify-content-between align-items-center">
                <div>
                    <h6 class="text-uppercase mb-1">食品总数</h6>
                    <div class="number">{{ total_foods }}</div>
                </div>
                <i class="fas fa-apple-alt fa-3x opacity-50"></i>
            </div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="stats-card mb-4">
            <div class="d-flex justify-content-between align-items-center">
                <div>
                    <h6 class="text-uppercase mb-1">类别总数</h6>
                    <div class="number">{{ total_categories }}</div>
                </div>
                <i class="fas fa-tags fa-3x opacity-50"></i>
            </div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="stats-card mb-4">
            <div class="d-flex justify-content-between align-items-center">
                <div>
                    <h6 class="text-uppercase mb-1">今日采购</h6>
                    <div class="number">{{ recent_purchases.count }}</div>
                </div>
                <i class="fas fa-shopping-cart fa-3x opacity-50"></i>
            </div>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-md-12">
        <div class="card">
            <div class="card-header d-flex justify-content-between align-items-center">
                <h5 class="mb-0">
                    <i class="fas fa-history me-2"></i>最近采购
                </h5>
                <a href="{% url 'food:purchase_list' %}" class="btn btn-light btn-sm">
                    查看全部 <i class="fas fa-arrow-right ms-1"></i>
                </a>
            </div>
            <div class="card-body">
                <div class="list-group list-group-flush">
                    {% for purchase in recent_purchases %}
                    <div class="list-group-item">
                        <div class="d-flex justify-content-between align-items-center">
                            <div>
                                <h6 class="mb-1">{{ purchase.food.name }}</h6>
                                <small class="text-muted">
                                    <i class="fas fa-box me-1"></i>{{ purchase.quantity }} {{ purchase.food.unit }}
                                    <i class="fas fa-tag ms-2 me-1"></i>{{ purchase.food.category.name }}
                                </small>
                            </div>
                            <div class="text-end">
                                <div>￥{{ purchase.price }}</div>
                                <small class="text-muted">{{ purchase.purchase_date }}</small>
                            </div>
                        </div>
                    </div>
                    {% empty %}
                    <div class="list-group-item text-center text-muted">
                        <i class="fas fa-inbox me-2"></i>暂无采购记录
                    </div>
                    {% endfor %}
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
